package day06;


import java.util.Arrays;

public class ArrayDemo {
    public static void main(String[] args) {
        int[] a = {1,2,3,4,5,8,6,41};
        int[] b = new int[a.length];

//        for (int i = 0; i <a.length ; i++) {
//            b[i] = a[i];
//        }
//        b = a;//a的地址赋值给b

//        System.arraycopy(a,2,b,0,5);//表示数组copy从a下标0开始到b下标开始，复制长度为length
//        for (int i = 0; i <b.length ; i++) {
//            System.out.println(b[i]);
//        }

        int max = 0;
        int[] c = new int[10];
        for (int i = 0; i <c.length ; i++) {
            c[i] =(int)(Math.random()*100+1);//插入数字
            System.out.print(c[i]+"  ");

        }


        System.out.println();
        for (int i = 0; i <c.length ; i++) {

            if (max<c[i]){//找出最大值
                max = c[i];
            }
        }

        System.out.println(max+" -------------           ");
        c= Arrays.copyOf(c,c.length+1);//数组扩容
        c[c.length-1] = max;
        for (int i = 0; i <c.length; i++) {
            System.out.print(c[i]+"  ");
        }

        System.out.println();
         Arrays.sort(c);//排序后的数组，
        for (int i = 0; i <c.length; i++) {
            System.out.print(c[i]+"  ");
        }
    }
}
